<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>登录</title>
    <link href="res/static/css/main.css" rel="stylesheet" type="text/css">
    <link href="res/layui/css/layui.css" rel="stylesheet" type="text/css">
    <script src="res/layui/layui.js" type="text/javascript"></script>
    <script src="res/static/js/util/jquery-3.3.1.min.js" type="text/javascript"></script>
    <meta content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0"
          name="viewport">
    <meta content="IE=Edge,chrome=1" http-equiv="X-UA-Compatible">
</head>
<body>

<div class="site-nav-bg">
    <div class="site-nav w1200">
        <p class="sn-back-home">
            <i class="layui-icon layui-icon-home"></i>
            <a href="/">首页</a>
        </p>
        <div class="sn-quick-menu">
            <div class="login"><a href="register.html">请注册</a></div>
        </div>
    </div>
</div>


<div class="header">
    <div class="headerLayout w1200">
        <div class="headerCon">
            <h1 class="mallLogo">
                <a href="index.html" title="极品商城">
                    <img src="res/static/img/logo.png" style="margin-top: 10px">
                </a>
            </h1>
        </div>
    </div>
</div>


<div class="content content-nav-base  login-content">

    <div class="login-bg">
        <div class="login-cont w1200">
            <div class="form-box">
                <form action="login" class="layui-form" method="post">
                    <legend>手机号登录</legend>
                    <div class="layui-form-item">
                        <div class="layui-inline iphone">
                            <div class="layui-input-inline">
                                <i class="layui-icon layui-icon-cellphone iphone-icon"></i>
                                <input autocomplete="off" class="layui-input" id="phone" lay-verify="required|phone"
                                       name="phone" placeholder="请输入手机号" type="tel">
                            </div>
                        </div>
                        <div class="layui-inline iphone">
                            <div class="layui-input-inline">
                                <i class="layui-icon layui-icon-password iphone-icon"></i>
                                <input autocomplete="off" class="layui-input" id="password"
                                       lay-verify="required|password"
                                       name="password" placeholder="请输入密码" type="password">
                            </div>
                        </div>
                        <div class="layui-inline veri-code">
                            <div style="width: 195px; display: inline-block;">
                                <input autocomplete="off" class="layui-input" id="pnum" lay-verify="required"
                                       name="verifiCode"
                                       placeholder="请输入验证码" type="text">
                            </div>
                            <img alt="验证码" id="captcha" onclick="updateCaptcha()"
                                 src="getCaptcha" style="width: 100px;height: 36px; border-width: 1px;">
                        </div>
                    </div>
                    <div class="layui-form-item login-btn">
                        <div class="layui-input-block" style="padding-top: 0px">
                            <input class="layui-btn" lay-filter="demo1" lay-submit="" name="submit"
                                   style="width: 300px; background-color:#FF794E;"
                                   type="submit" value="登录">
                        </div>
                    </div>
                </form>
                <p style="text-align: center; color: gray">没有帐号？<a href="register.html">请注册</a></p>
            </div>
        </div>
    </div>
</div>

<div class="footer">
    <div class="ng-promise-box">
        <div class="ng-promise w1200">
            <p class="text">
                <a class="icon1" href="javascript:">7天无理由退换货</a>
                <a class="icon2" href="javascript:">满99元全场免邮</a>
                <a class="icon3" href="javascript:" style="margin-right: 0">100%品质保证</a>
            </p>
        </div>
    </div>
    <div class="mod_help w1200">
        <p>
            <a href="javascript:">关于我们</a>
            <span>|</span>
            <a href="javascript:">帮助中心</a>
            <span>|</span>
            <a href="javascript:">售后服务</a>
            <span>|</span>
            <a href="javascript:">极品资讯</a>
            <span>|</span>
            <a href="javascript:">关于货源</a>
        </p>
        <p class="coty">极品商城版权所有 &copy; 2012-2020</p>
    </div>
</div>
<script type="text/javascript">
    layui.config({
        base: 'res/static/js/util' //你存放新模块的目录，注意，不是layui的模块目录
    }).use(['jquery', 'form'], function () {
        var $ = layui.$, form = layui.form;

        $("#find").click(function () {
            if (!/^1\d{10}$/.test($("#phone").val())) {
                layer.msg("请输入正确的手机号");
                return false;
            }
            var obj = this;
            $.ajax({
                type: "post",
                url: "json/login.json",
                dataType: "json",//返回的
                success: function (data) {

                    if (data.result) {
                        $("#find").addClass(" layui-btn-disabled");
                        $('#find').attr('disabled', "true");
                        settime(obj);
                        $("#msg").text(data.msg);
                    } else {
                        layer.msg(data.msg);
                    }
                },
                error: function (msg) {
                    console.log(msg);
                }
            });
        });
        var countdown = 60;

        function settime(obj) {
            if (countdown == 0) {
                obj.removeAttribute("disabled");
                obj.classList.remove("layui-btn-disabled");
                obj.value = "获取验证码";
                countdown = 60;
                return;
            } else {

                obj.value = "重新发送(" + countdown + ")";
                countdown--;
            }
            setTimeout(function () {
                    settime(obj)
                }
                , 1000)
        }
    })
</script>
<script type="text/javascript">
    function updateCaptcha() {
        random = new Date().getTime() + '' + Math.floor(Math.random() * Math.pow(10, 8));
        $('#captcha').attr('src', '/getCaptcha?rand=' + random);
    }

    $(function () {
        // 想要获取的cook键值

        // 调用
        var x = getCookie("userTel");
        if (x != null && x !== "") {
            window.location.href = "index.html";
        }


        function getCookie(cname) {
            var name = cname + "=";
            var ca = document.cookie.split(';');
            for (var i = 0; i < ca.length; i++) {
                var c = ca[i].trim();
                if (c.indexOf(name) == 0) return c.substring(name.length, c.length);
            }
            return "";
        }

    })
</script>


</body>
</html>